<template>
  <nav class="navbar navbar-expand-lg navbar-dark">
    <div class="container">
      <router-link
        class="navbar-brand animate__animated animate__bounceInLeft"
        :to="{ name: 'home' }"
        >BC12's SNAKE</router-link
      >
      <div class="collapse navbar-collapse" id="navbarText">
        <ul class="navbar-nav me-auto mb-2 mb-lg-0">
          <li class="nav-item animate__animated animate__bounceInLeft">
            <router-link
              :class="route_name == 'pk_index' ? 'nav-link active' : 'nav-link'"
              :to="{ name: 'pk_index' }"
              >PLAY</router-link
            >
          </li>
          <li class="nav-item animate__animated animate__bounceInLeft">
            <router-link
              :class="route_name == 'record_index' ? 'nav-link active' : 'nav-link'"
              :to="{ name: 'record_index' }"
              >对局列表</router-link
            >
          </li>
          <li class="nav-item animate__animated animate__bounceInLeft">
            <router-link
              :class="route_name == 'ranklist_index' ? 'nav-link active' : 'nav-link'"
              :to="{ name: 'ranklist_index' }"
              >排行榜</router-link
            >
          </li>
        </ul>
        <ul class="navbar-nav" v-if="$store.state.user.is_login">
          <li class="nav-item animate__animated animate__bounceInRight">
            <router-link
              :class="route_name == 'rule_index' ? 'nav-link active' : 'nav-link'"
              :to="{ name: 'rule_index' }"
              >游戏规则</router-link
            >
          </li>
          <li class="nav-item animate__animated animate__bounceInRight">
            <router-link
              :class="route_name == 'rule_index' ? 'nav-link active' : 'nav-link'"
              :to="{ name: 'rule_index' }"></router-link>
          </li>
          <li class="nav-item animate__animated animate__bounceInRight">
            <router-link
              :class="route_name == 'user_bot_index' ? 'nav-link active' : 'nav-link'"
              :to="{ name: 'user_bot_index' }"
              >个人空间</router-link
            >
          </li>
        </ul>

        <ul class="navbar-nav" v-else-if="!$store.state.user.pulling_info">
          <li class="nav-item animate__animated animate__bounceInRight">
            <router-link class="nav-link" :to="{ name: 'user_account_login' }" role="button">
              登录
            </router-link>
          </li>
          <li class="nav-item animate__animated animate__bounceInRight">
            <router-link class="nav-link" :to="{ name: 'user_account_register' }" role="button">
              注册
            </router-link>
          </li>
        </ul>
      </div>
    </div>
  </nav>
</template>

<script>
import { useRoute } from "vue-router";
import { computed } from "vue";
import { useStore } from "vuex";

export default {
  setup() {
    const store = useStore();
    const route = useRoute();
    let route_name = computed(() => route.name);

    const logout = () => {
      store.dispatch("logout");
    };

    return {
      route_name,
      logout,
    };
  },
};
</script>

<style scoped>
.navbar {
  background-color: rgba(50, 50, 50, 0.66);
  z-index: 999;
}

.navbar-nav .nav-item:hover .nav-link {
  color: rgb(13, 202, 240);
}

.dropdown-menu {
  background-color: rgba(50, 50, 50, 0.66); /* 设置背景颜色为半透明灰色 */
}

.dropdown-item {
  background-color: transparent; /* 设置选项的背景颜色为透明 */
}

.dropdown-menu li a {
  color: rgb(166, 172, 180);
}
.dropdown-menu li a:hover {
  color: rgb(13, 202, 240);
}
</style>
